﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using DevExpress.Xpo;
using Component;

public partial class FrontEnd_Body_Left_ImgDetail : System.Web.UI.UserControl
{
    public XPCollection<ProductImg> _xpProImg = new XPCollection<ProductImg>(KetNoiCSDL.session);
    //public string _ProductImg = "";
    //public int _pagemaxKH = 0;
    //public string _Start = "";
    public string _PathImgBig = "";
    public string _Extension = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        int idProduct = ConvertType.ToInt(QueryHelper.GetQueryString(Request, ConstString._id));
        _xpProImg = ProductImgDB.GetAllObjByIdProduct(idProduct);
        if (_xpProImg.Count<=0)
        {
            _PathImgBig = ProductDB.GetObjectByid(idProduct,false) != null ? ProductDB.GetObjectByid(idProduct,false).Img : "";
            return;
        }
        else
        {
            _PathImgBig = _xpProImg[0].PathImgBig.Substring(0, _xpProImg[0].PathImgBig.LastIndexOf("/"));
            _Extension = _xpProImg[0].PathImgBig.Split('.')[1];
        }
        //int dem = 0;
        //foreach (ProductImg img in _xpProImg)
        //{
        //    if (dem < 4)
        //        _Start += @"<a id=""aKH" + dem + @"""rel=""lightbox"" href=""" + img.PathImgBig + @"""><img src=""" + img.PathImgSmall + @""" border=""none"" class=""bg_hinhanhthem""/></a>";
        //    _ProductImg += string.Format("{0},{1};", img.PathImgSmall, img.PathImgBig);
        //    dem++;
        //}
        //if (_ProductImg == "")
        //    return;
        //else
        //    _ProductImg = _ProductImg.Substring(0, _ProductImg.Length - 1);
        //_ProductImg += "";
        //_pagemaxKH = _xpProImg.Count % 4 == 0 ? (_xpProImg.Count / 4) : ((_xpProImg.Count / 4) + 1);
    }
}
